from api.login import LoginAPI
from api.course import CourseAPI


class TestDeleteCourseAPI:
    TOKEN = None

    def setup_method(self):
        self.login_api = LoginAPI()
        self.course_api = CourseAPI()
        response_v = self.login_api.get_verify_code()
        login_data = {
            "username": "admin",
            "password": "HM_2023_test",
            "code": 2,
            "uuid": response_v.json().get("uuid")
        }
        response_l = self.login_api.login(test_data=login_data)
        TestDeleteCourseAPI.TOKEN = response_l.json().get("token")
        print(TestDeleteCourseAPI)

    def test01_delete_success(self):
        response = self.course_api.delete_course(course_id=1, token=TestDeleteCourseAPI.TOKEN)
        print(response.json())
        assert 200 == response.status_code
        assert "成功" in response.text
        assert 200 == response.json().get("code")
